﻿/*************************************************
** 功能 : 时间类的设计与实现
/**************************************************/

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
/*----------------------------------*
		定义时间类
*-----------------------------------*/
class Time
{
	//成员变量
   int hour, minute, second;

//构造函数
public:
Time()//1
{
	cout << "无参构造函数被自动调用" << endl;
}
Time(int h2, int m2, int s2)//2
{
	this->hour = h2;
	this->minute = m2;
	this->second = s2;
	cout << "有参构造函数被自动调用" << endl;
}
//Time(int h3 = 12, int m3 = 0, int s3=32)//3
//{
//	this->hour = h3;
//	this->minute = m3;
//	this->second = s3;
//	cout << "默参构造函数被自动调用" << endl;
//}
Time(Time &r)//4
{
	hour = r.hour;
	minute = r.minute;
	second = r.second;
	cout << "拷贝构造函数被自动调用" << endl;
}
//析构函数
~Time()
{
	cout << "~析构函数被自动调用(继续按回车)" << endl;
	getchar();
}

//普通功能函数
void setHour(int h);  //设置小时
void setMinute(int m);//设置分钟
void setSecond(int s);//设置秒数
void show(int h, int m ,int s);//输出时间
};



/*----------------------------------*
		   主函数
*-----------------------------------*/

int main()
{
	Time t0;
	//1. 生成时间类的对象
	Time t1;
	Time t2();
	Time t3(24, 00, 00);
	Time t4 = t1;
	Time t5;
	t5 = t1;
	int h1=0, m1=0, s1=0;

	//2. 输出各时间对象信息
	t0.show(h1,s1,m1);
	t1.show(h1,s1,m1);
	t2().show(h1, s1, m1);
	t3.show(h1, s1, m1);
	t4.show(h1, s1, m1);
	t5.show(h1, s1, m1);
}
void Time::setHour(int h)
{
	this->hour = h;
}

void Time::setMinute(int m)
{
	this->minute = m;
}

void Time::show(int h, int m, int s)
{
	cout << "Time is " << h << ":" << m << ":" << s << endl;
}